import jakarta.servlet.*;

import java.io.IOException;
import java.io.PrintWriter;

public class DemoServlet implements Servlet {
    private String servletName;

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        servletName = servletConfig.getServletName();
    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        servletResponse.setContentType("text/html;charset=utf-8");
        //servletResponse.setCharacterEncoding("UTF-8");
        PrintWriter out = servletResponse.getWriter();
//        servletResponse.getOutputStream();
//        getServletConfig().getServletContext()
        out.println("这是我们的Servlet页面，Hello！！！<br>");
        out.println(servletName);
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
